{extend name="AdminEx/index" /}
{css href="/static/css/toastr.min.css"}
{block name="main"}
<div class="col-md-12">
    <div class="col-md-7">
        <table class="table table-striped">
            <tr>
                <th class="col-md-10">消息</th>
                <th>操作</th>
            </tr>
            {foreach name="data" id="v"}
            <tr>
                <td class="col-md-10">{$v.sysmsg}</td>
                <td><a href="{:url('admin/Mess/delete',['id'=>$v['id']])}">删除</a></td>
            </tr>
            {/foreach}
        </table>

</div>
    <div class="col-md-5">

                         <h1 class="col-md-offset-2"><a id="info">点击发布系统消息</a></h1>
        <textarea class="form-control" rows="8"></textarea>
    </div>
</div>
{js href="/static/layout/js/jquery-1.10.2.min.js" }
{js href="/static/js/toastr.min.js"}
<script>
    $(function(){
        // 设置弹框参数
        toastr.options = {
            closeButton: true,// 是否显示关闭按钮
            progressBar: true,// 实现显示计时条
            timeOut: "3000",  // 自动关闭时间
            positionClass: "toast-top-right" // 提示位置
            // toast-top-full-width 顶端，宽度铺满整个屏幕
            // toast-top-right  顶端右边
        };

        $('#info').click(function(){
            var mess = $('textarea').val();
            addinfo(mess);
        });

    });

    function addinfo(mess) {
        $.ajax({
            data:{'mes':mess},
            type: 'post',
            url: '/message/',
            dataType:'json',
            success: function (data) {
                if (data.status) {
                    toastr.success(data.info);
                    setTimeout('window.location.reload()'
                ,'1000');
                } else {
                    toastr.error(data.info, 'FBI WARING:');
                }
            },
            error: function () {
                toastr.error('', 'FBI WARING:');
            }
        });
    }
</script>
{/block}


